package com.lb.api;

import lombok.Data;

import javax.servlet.http.HttpServletRequest;

/**
 * 请求日志
 *
 * @author xiemingzhi
 * @since 1.0
 */
@Data
public class ApiLogRequest {

    private String userId;
    private String method;
    private String queryString;
    private String requestURL;
    private String contentType;
    private Object body;

    public static ApiLogRequest build(HttpServletRequest request) {
        ApiLogRequest apiLogRequest = new ApiLogRequest();
        apiLogRequest.setMethod(request.getMethod());
        apiLogRequest.setQueryString(request.getQueryString());
        apiLogRequest.setRequestURL(request.getRequestURL().toString());
        apiLogRequest.setContentType(request.getContentType());
        return apiLogRequest;
    }
}
